package leetcode.秋招.广;

import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/9/17 21:32
 * @description：
 */
public class Main3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String S = in.next();
        String T = in.next();
        int[] nums = new int[26];
        for (int i = 0; i < T.length(); i++) {
            char c = T.charAt(i);
            nums[c - 'a']++;
        }
        StringBuilder builder = new StringBuilder();
        for (int i = 0; i < S.length(); i++) {
            char c = S.charAt(i);
            int num = nums[c - 'a'];
            nums[c - 'a'] = 0;
            while (num > 0) {
                builder.append(c);
                num--;
            }
        }
        for (int i = 0; i < nums.length; i++) {
            if (nums[i] != 0) {
                int num = nums[i];
                while (num > 0) {
                    builder.append((char)(i + 'a'));
                    num--;
                }
            }
        }
        System.out.println(builder.toString());
    }
}
